<?php
require_once("../Config.php");
require_once("User.php");
require_once("MsgStack.php");
session_start();
if($_GET['action']=='login'){
  if(!isset($_POST['username'])||!isset($_POST["password"])||$_POST['username']==""||$_POST['password']==""){
    $message="Please input your username and password!";
    
  }else{
    $sql_ = "select * from user where username='".$_POST['username']."' and password='".$_POST['password']."'";
    $result_ = mysql_query($sql_);
   // echo $sql_;
   // exit();
    $row = mysql_fetch_row($result_);
     if(!$row){      
      $message="Wrong username or password!";
     }else{
       
       $_SESSION['TWI_USR']=$_POST['username'];
       header("Location:index.php");
       exit();
     }
   

  }
}


?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>
      Welcome!
    </title>
    <link href="css/admin-common.css" rel="stylesheet" type="text/css">
    <link type="text/css" href="css/ui-lightness/jquery-ui-1.7.3.custom.css" rel="stylesheet" />
    <script type="text/javascript" src="../js/jquery.js">
    </script>
    <script type="text/javascript" src="js/common.js"></script>
      <script type="text/javascript" src="js/jquery-ui-1.7.3.custom.min.js"></script>
  
  </head>
  <script type="text/javascript">
    var app={
        init: function() {
        }
      }
      </script>
      <body>
      <p>
      <?php echo $message;?>
      </p>
      <div id="#validFailureDlg" style="display:none">
        Username and Password are all required!
      </div>
      <h3>Twilightcocktailbar.com Content Managerment</h3>
    <hr/>
   <strong style="display:none;color:#C92C24;clear:both"> Notice:Remember well your username and passwod after you update them!!!</strong>
    
  
  <form action="?action=login" method="post">
 <p> <label>
    <span>username</span><input type="text" id="username" name="username"  />
    </label>
    
    <label>
    <span>password</span><input type="password" id="password" name="password"  />
    </label>
    </p>
    <p>
    <input type="submit" value="login"/>
    </p>
    </form>
    
      </body>
      </html>